﻿
using Demo.DemoFeature.ApiModels.Points;

using GCC.APIContainer.Auth.Attributes;
using GCC.APIContainer.Utilities;
using GCC.Container.Abstracts;
using GCC.Container.Models;

using Microsoft.AspNetCore.Mvc;

namespace Demo.DemoFeature
{
    [ApiController]
    [Route("Demo")]
    public class PointsController : GCCAPIControllerBase
    {
        public PointsController(AbsGCCContext context) : base(context)
        {
        }


        [HttpGet("Points/items")]
        [GCCAuth(allowOffline: true, roles: new string[] { "admin" })]
        public DataResponse<List<PointsResponse>> AllAlivePoints()
        {
            var allPoints = GCCContext.GetConfigByPath(new string[] { "SystemCenter", "PointsList" });
            if (string.IsNullOrWhiteSpace(allPoints))
            {
                return HandleData(new List<PointsResponse>());
            }
            return HandleData(System.Text.Json.JsonSerializer.Deserialize<List<PointsResponse>>(allPoints, LuanNiao.JsonConverterExtends.CommonSerializerOptions.CamelCaseChineseNameCaseInsensitive) ?? new List<PointsResponse>());
        }


    }
}
